﻿using System;
using System.Collections;
using System.Windows.Data;

namespace ItemsViewer
{
    /// <summary>
    /// This class represents a Custom ListCollectionView with FilterAnimated property.
    /// </summary>
    public class FilterAnimatedListCollectionView : ListCollectionView
    {
        /// <summary>
        /// The filter animated.
        /// </summary>
        private Predicate<object> filterAnimated;

        /// <summary>
        /// Initializes a new instance of the FilterAnimatedListCollectionView class.
        /// </summary>
        /// <param name="list">The underlying collection, which must implement System.Collections.IList.</param>
        public FilterAnimatedListCollectionView(IList list): base(list)
        { }

        /// <summary>
        /// The EventHandler FilterAnimatedUpdated.
        /// </summary>
        public virtual event EventHandler FilterAnimatedUpdated;

        /// <summary>
        /// The EventHandler FilterAnimatedCompleted.
        /// </summary>
        public virtual event EventHandler FilterAnimatedCompleted;

        /// <summary>
        /// Gets or sets Filter Animated.
        /// </summary>
        public Predicate<object> FilterAnimated
        {
            get
            {
                return this.filterAnimated;
            }

            set
            {
                this.filterAnimated = value;
                if (this.FilterAnimatedUpdated != null)
                {
                    this.FilterAnimatedUpdated(this, new EventArgs());
                }
            }
        }

        /// <summary>
        /// Refresh Filter animated.
        /// </summary>
        public void RefreshFilterAnimated()
        {
            if (this.FilterAnimatedUpdated != null)
            {
                this.FilterAnimatedUpdated(this, new EventArgs());
            }
        }

        /// <summary>
        /// Raise event when Filter animation is completed.
        /// </summary>
        public void RaiseFilterAnimatedCompleted()
        {
            if (this.FilterAnimatedCompleted != null)
            {
                this.FilterAnimatedCompleted(this, new EventArgs());
            }
        }
    }
}
